import type { IPostTemplate } from '@/interfaces';
import { formatDate } from '@/lib/tool';

export default function QueryPostTemplateInfo({
  details,
}: {
  details: IPostTemplate;
}) {
  return (
    <div className="row">
      <div className="col">
        <div className="card">
          <div className="card-header bg-transparent text-muted">
            <i className="bi bi-info-square me-2"></i>
            {details.name}
          </div>
          <div className="card-body">
            <div className="table-responsive">
              <table className="table table-hover align-middle table-striped">
                <thead>
                  <tr className="text-nowrap">
                    <th scope="col" className="fw-normal">
                      ID
                    </th>
                    <th scope="col" className="fw-normal">
                      {details.id}
                    </th>
                  </tr>
                </thead>
                <tbody>
                  {Object.keys(details)
                    .filter((item) => !['id', 'content'].includes(item))
                    .map((item) => {
                      return (
                        <tr key={item} className="text-nowrap">
                          <td>
                            {item === 'createdBy' && '创建用户'}

                            {item === 'updatedBy' && '更新用户'}

                            {item === 'creatorAlias' && '创建者别名'}

                            {item === 'updaterAlias' && '更新者别名'}

                            {item === 'createdOn' && '创建时间'}

                            {item === 'updatedOn' && '更新时间'}

                            {item === 'deleted' && '是否删除'}

                            {item === 'name' && '帖子模板名称'}

                            {item === 'overview' && '概述'}

                            {item === 'sort' && '排序'}

                            {item === 'section' && '版块'}
                          </td>
                          <td>
                            {item === 'createdBy' && details[item]}

                            {item === 'updatedBy' && details[item]}

                            {item === 'creatorAlias' && details[item]}

                            {item === 'updaterAlias' && details[item]}

                            {item === 'createdOn' && formatDate(details[item])}

                            {item === 'updatedOn' && formatDate(details[item])}

                            {item === 'deleted' && details[item] + ''}

                            {item === 'name' && details[item]}

                            {item === 'overview' && details[item]}

                            {item === 'sort' && details[item]}

                            {item === 'section' &&
                              `${details[item].name}（${details[item].id}）`}
                          </td>
                        </tr>
                      );
                    })}
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}
